﻿using Prism.Services.Dialogs;
using System;

namespace SmartPlant.Core
{
    /// <summary>
    /// 对话框助手。
    /// </summary>
    public static class DialogHelper
    {
        /// <summary>
        /// 显示消息提示对话框。
        /// </summary>
        /// <param name="dialog"></param>
        /// <param name="message"></param>
        /// <param name="callback"></param>
        public static void ShowAltert(this IDialogService dialog, string message, Action<IDialogResult> callback = null)
        {
            dialog.ShowDialog("AlertDialog",
                   new DialogParameters($"message={message}"),
                   r =>
                   {
                       callback?.Invoke(r);
                   });
            return;
        }

        /// <summary>
        /// 显示消息提示对话框。
        /// </summary>
        /// <param name="dialog"></param>
        /// <param name="message"></param>
        /// <param name="callback"></param>
        public static void ShowMessage(this IDialogService dialog, string message, Action<IDialogResult> callback = null)
        { 
            dialog.ShowDialog("MessageDialog",
                   new DialogParameters($"message={message}"),
                   r =>
                   {
                       callback?.Invoke(r);
                   }); 
            return;
        }

        /// <summary>
        /// 显示消息提示对话框。
        /// </summary>
        /// <param name="dialog"></param>
        /// <param name="message"></param>
        /// <param name="callback"></param>
        public static void ShowQuestion(this IDialogService dialog, string message, Action<IDialogResult> callback = null)
        {
            dialog.ShowDialog("QuestionDialog",
                   new DialogParameters($"message={message}"),
                   r =>
                   {
                       callback?.Invoke(r);
                   });
            return;
        }
    }
}
